<template>
	<view>
		<view class="List">
			<view class="p-header" style="border-bottom: 1rpx solid #f4f4f4;">
				<view class="p-name">
					填写信息
				</view>
				<view class="p-status" style="background-color: #669bf9;color: #fff;" @tap="customer" v-if="st == 1">
					选择客户
				</view>
			</view>
			<view class="p-content" v-if="st == 1">
				<view class="p-left">
					客户姓名
				</view>
				<view class="p-right">
					<input type="text" v-model="customerinfo.name" disabled placeholder="请选择客户信息" />
				</view>
			</view>
			<view class="p-content" v-if="st == 1">
				<view class="p-left">
					客户电话
				</view>
				<view class="p-right">
					<input type="text" v-model="customerinfo.tel" disabled placeholder="请选择客户信息" />
				</view>
			</view>
			<view class="p-content">
				<view class="p-left">
					30日租金
				</view>
				<view class="p-right">
					<input type="number" v-model="rimoney" placeholder="不满30天按照30天计算" />
				</view>
			</view>
			<view class="p-content">
				<view class="p-left">
					重量/KG
				</view>
				<view class="p-right">
					<input type="number" v-model="product" placeholder="请输入重量" />
				</view>
			</view>
			<view class="p-content">
				<view class="p-left">
					租借押金
				</view>
				<view class="p-right">
					<input type="number" v-model="yajin" placeholder="请输入租借押金" />
				</view>
			</view>
			<view class="p-content">
				<view class="p-left">
					液化气收费
				</view>
				<view class="p-right">
					<input type="number" v-model="price" placeholder="请输入价格" />
				</view>
			</view>
			<view class="p-content" v-if="st == 1">
				<view class="p-left">
					客户地址
				</view>
				<view class="p-right">
					<input type="text" v-model="customerinfo.address" disabled placeholder="请选择客户信息" />
				</view>
			</view>
			<view class="p-contents" style="padding-bottom: 40rpx;">
				<view class="p-top">
					备注
				</view>
				<view class="p-bottom">
					<textarea placeholder="请输入备注" v-model="remark" cols="30" rows="10"></textarea>
				</view>
			</view>
		</view>
		<view class="sub-btn">
			<view class="submit" @tap="submit">
				提交资料
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				zguanzi_id: '',
				customerinfo: '', //客户信息
				zuri: '请选择租借日期',
				guiri: '请选择归还日期',
				yajin: '',
				money: '',
				zujin: '',
				day:0,
				product:'', //重量
				rimoney:'',
				price:'',
				remark:'',
				st:0
			}
		},
		onShow() {
			this.st = uni.getStorageSync('st')
		},
		onLoad(options) {
			this.zguanzi_id = options.id
			this.zujin = options.zujin
			this.yajin = options.yajin
			uni.$on('customer', (res) => {
				this.customerinfo = res
			})
		},
		methods: {
			submit() {
				if (!this.customerinfo.id) {
					uni.showToast({
						title: '请选择客户信息',
						icon: 'none'
					})
					return
				}
				if (!this.product) {
					uni.showToast({
						title: '请填写重量',
						icon: 'none'
					})
					return
				}
				if (!this.rimoney) {
					uni.showToast({
						title: '请填写30天租金',
						icon: 'none'
					})
					return
				}
				if (!this.yajin) {
					uni.showToast({
						title: '请填写押金',
						icon: 'none'
					})
					return
				}
				uni.showToast({
					title: '正在加载'
				})
				this.$http.Post('cper/guanzu', {
					zkehu_id: this.customerinfo.id, //客户ID
					zguanzi_id: this.zguanzi_id, //产品ID
					product:this.product,//重量
					yajin: this.yajin, //押金
					price: this.price, //租借费用
					rimoney:this.rimoney,
					remarks:this.remark
				}, (result) => {
					uni.showToast({
						title: result.msg,
						icon: 'none'
					})
					setTimeout(res => {
						uni.switchTab({
							url: '/pages/index/index'
						})
					}, 600)
				})
			},
			customer() {
				uni.navigateTo({
					url: '/pages/form/customer'
				})
			}
		}
	}
</script>

<style>
	.List {
		margin: 20rpx auto;
		width: 94%;
		border-radius: 16rpx;
		background-color: #fff;
	}

	.p-header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 94%;
		margin: 0 auto;
		height: 90rpx;
	}

	.p-name {
		font-weight: bold;
	}

	.p-status {
		border-radius: 8rpx;
		font-size: 28rpx;
		padding: 5rpx 12rpx;
		background-color: #f0f5fc;
		color: #669bf9;
	}

	.from {
		padding: 20rpx 0;
		width: 94%;
		border: 1rox solid black;
		margin: 20rpx auto;
		background-color: #fff;
		border-radius: 16rpx;
	}

	.p-content {
		width: 94%;
		margin: 20rpx auto;
		display: flex;
		align-items: center;
		color: #7a7a7a;
		font-size: 30rpx;
		height: 65rpx;
	}
	
	

	.p-left {
		width: 25%;
		height: 100%;
		display: flex;
		align-items: center;
		font-weight: bold;

	}
	
	.p-contents {
		width: 94%;
		margin: 20rpx auto;
		color: #7a7a7a;
		font-size: 30rpx;
	}
	.p-top{
		width: 100%;
		height: 100%;
		display: flex;
		align-items: center;
		font-weight: bold;
	}
	
	.p-bottom{
		padding-top: 30rpx;
	}

	.p-right {
		width: 75%;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		text-align: right;
		color: #000;
	}

	.sub-btn {
		position: fixed;
		bottom: 0;
		width: 100%;
		height: 120rpx;
		background-color: #fff;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.submit {
		width: 94%;
		height: 90rpx;
		border-radius: 16rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		color: #fff;
		font-size: 28rpx;
		background-color: #669bf9;
	}
</style>